//{=======================================================================
//! @file C1.c
//! @date 05.10.2013 4:05
//! @author Andrey Drobyshev <immortalguardian1@gmail.com>
//! @ version 1.0
//!
//! @par	Conditions:
//! 		The program reads a non-negative number and checks out if it's
//!         possible to weigh that mass with the only bobs that
//!         all the degrees of number 4. Repetitions are prohibited.
//}=======================================================================

#include <stdio.h>

//{=================================================================================
//! Function check - evidently, solves the main program's problem:
//! checks out if it possible to weigh a given mass.
//!
//! @param      mass    an original mass
//!
//! @return     nothing
//!
//! @note       The function uses recursive algorithm.
//}==================================================================================

void check (unsigned int mass);

//{==============================================================
//! Function main - prints welcome messages and the result,
//! manages all the program execution.
//!
//! @return     0 on success
//!
//! @note       The function uses the function "check".
//}===============================================================

int main ()
{
	printf ( "#Hello!\n"
             "#The program checks out if it's "
             "possible to weigh the mass with the only bobs that "
             "are all the degrees of number 4 (1, 4, 16, ...). Repetitions are prohibited.\n"
             "#Please enter the mass: ");
    printf( "\n");

    unsigned int mass = 0;

	scanf ( "%u", &mass);
	check ( mass);
	return 0;
}

void check (unsigned int mass)
{
	switch ( mass)
	{
        case 0:
            printf ( "No, it's impossible.\n");
            return;
        case 1:
            printf ( "Yes, it's possible.\n");
            return;
        default:
            switch ( mass % 4)
            {
                case 0:
                case 1:
                    check ( mass / 4);
                    break;
                case 2:
                    printf ( "No, it's impossible.\n");
                    return;
                case 3:
                    check ( mass / 4 +1);
                    break;
            return;
            }
    }
}
